#include <bits/stdc++.h>

using std::swap;

const int mod=10086;
const int maxn=100005;

struct iostream{
	FILE *i,*o;
	const static int bufsiz = 1000000;
	iostream(FILE *i,FILE *o):i(i),o(o){}
	inline const char getc(){
		static char buf[bufsiz];
		static int pos=bufsiz,end=bufsiz;
		if(pos==end) end=fread(buf,1,bufsiz,i),pos=0;
		if(pos==end) return EOF;
		return buf[pos++];
	}
	template <typename T>inline iostream& operator >> (T &r){
		char c;bool f=0;
		for(c=getc();c>'9'||c<'0';c=getc()) if(c=='-') f=1;
		for(r=0;c<='9'&&c>='0';c=getc()) r=r*10+c-'0';
		if(f) r=-r;
		return *this;
	}
	inline void putc(char c,bool flush=0){
		static char buf[bufsiz];
		static int pos=0;
		if(c) buf[pos++]=c;
		if(pos==bufsiz||flush) fwrite(buf,pos,1,o),pos=0;
	}
	template <typename T>inline iostream& operator << (T r){
		static int sta[50];
		int len=0;
		if(r<0){putc('-');r=-r;}
		while(r) sta[len++]=r%10,r/=10;
		while(len--) putc(sta[len]+'0');
		return *this;
	}
	inline void operator ++ (int){putc('\n');}
	~iostream(){
		putc(0,1);
	}
};

iostream io(stdin,stdout);
int a[maxn];

inline int Gauss(const int &n){
	int cnt=0;
	for(int mask=1<<30;mask;mask>>=1){
		int i;
		for(i=cnt;i<n;i++) if(a[i]&mask) {swap(a[i],a[cnt]);break;}
		if(i>=n) continue;
		for(i=0;i<n;i++) if(i!=cnt&&a[i]&mask) a[i]^=a[cnt];
		cnt++;
	}
	return cnt;
}

inline int qpow(int base,int exp){
	int ans=1;
	while(exp){
		if(exp&1) ans=ans*base%mod;
		base=base*base%mod;
		exp>>=1;
	}
	return ans;
}

int main(){
	int n,q,cnt,now,ans;

	freopen("2844.in","r",stdin);
	freopen("2844.out","w",stdout);

	io>>n;
	for(int i=0;i<n;i++) io>>a[i];
	io>>q;
	cnt=Gauss(n);
	ans=now=0;
	for(int i=0;i<cnt;i++){
		if((now^a[i])<q){
			ans+=qpow(2,cnt-i-1);ans%=mod;
			now^=a[i];
		}
	}
	if(q) ans++;
	ans*=qpow(2,n-cnt);ans++;ans%=mod;
	io<<ans;

	return 0;
}